package cn.gok.util;

/**
 * @author: 鸭鸭
 * @ClassName:ResultData
 * @Package:cn.gok.gokhappymall.util
 * @Description:
 * @date: 2021/8/3
 * @time: 16:33
 */
public class ResultData<T> {
    /**
     * 响应状态码
     */
    private String status;
    /**
     * 响应的数据
     */
    private T data;

    /**
     * 响应的提示信息
     */
    private String msg;

    public ResultData() {
    }

    public ResultData(String status, T data, String msg) {
        this.status = status;
        this.data = data;
        this.msg = msg;
    }

    public static ResultData success(){
        return new ResultData(ResponseCode.SUCCESS.getCode(),null,ResponseCode.SUCCESS.getMsg());
    }
    /**
     *
     * @param msg
     * @return
     */
    public static ResultData success(String msg){
        return new ResultData(ResponseCode.SUCCESS.getCode(),null,msg);
    }

    public static<T> ResultData createData(T data){
        return new ResultData(ResponseCode.SUCCESS.getCode(),data,ResponseCode.SUCCESS.getMsg());
    }


    public static ResultData fail(){
        return new ResultData(ResponseCode.FAIL.getCode(),null,ResponseCode.FAIL.getMsg());
    }

    public static ResultData fail(String msg){
        return new ResultData(ResponseCode.FAIL.getCode(),null,msg);
    }

    public static ResultData fail_login(String msg){
        return new ResultData(ResponseCode.FAIL_LOGIN.getCode(),null,msg);
    }
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
